<!--
 * @Author: 黄宇/Hyuishine
 * @Date: 2025-02-28 14:17:58
 * @LastEditors: 黄宇/Hyuishine
 * @LastEditTime: 2025-02-28 15:09:56
 * @Description: 
 * @Email: hyuishine@gmail.com
 * @Company: 3xData
 * @youWant: add you want
-->
<template>
  <uni-popup ref="popup"
             type="bottom"
             border-radius="10rpx 10rpx 0 0">
    <view class="container_popup">
      <view class="title"> 用户隐私保护提示 </view>
      <view class="content">感谢您使用本系统，使用本系统时会收集部分信息用于备案或执业操作。详情请见下方</view>
      <view class="urlFile"
            @click="openFile()"> 《江西消防技术服务小程序隐私保护指引》</view>
      <view>当您点击同意时，即表示您同意我们收集、使用、存储、处理您的相关信息。如您不同意，请立即终止使用本系统。</view>

      <view style="display: flex;">
        <button type="warn"
                @click="btn_disagree()">不同意并退出</button>
        <button type="primary"
                open-type="agreePrivacyAuthorization"
                @agreeprivacyauthorization="btn_agree">同意并继续</button>
      </view>
    </view>
  </uni-popup>
</template>
<script>
export default {
  data () {
    return {
      show: false
    }
  },
  methods: {
    showPopup () {
      this.show = true
      this.$refs.popup.open()
    },
    hidePopup () {
      this.show = false
      this.$refs.popup.close()
    },
    btn_disagree () {
      this.hidePopup()
      wx.exitMiniProgram()
    },
    btn_agree () {
      this.hidePopup()
    },
    openFile () {
      wx.openPrivacyContract({
        success: res => {
          console.log('openPrivacyContract success')
        },
        fail: res => {
          console.error('openPrivacyContract fail', res)
        }
      })
    }
  },
  onLoad () {
    console.log("onLoad")
    if (wx.getPrivacySetting) {
      wx.getPrivacySetting({
        success: res => {
          console.log("是否需要授权：", res.needAuthorization, "隐私协议的名称为：", res.privacyContractName)
          console.log(res)
          if (res.needAuthorization) {
            this.showPopup()
          }
        },
        fail: () => { },
        complete: () => { },
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.container_popup {
  background: white;
  padding: 24rpx;
  line-height: 40rpx;
  border-radius: 10rpx 10rpx 0 0;
  .title {
    font-weight: bold;
    color: #333;
    margin-bottom: 20rpx;
    font-size: 32rpx;
  }
  .urlFile {
    color: blue;
    cursor: pointer;
  }
  view {
    margin-bottom: 24rpx;
  }
}
</style>